#include<iostream>
#include<string>
using namespace std;
string s = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void x_to_n(int r,int m){
	if(r >= m)  x_to_n(r / m,m);
	cout << s[r % m];
}
int main(){
	int n,m;
	string s1,s2;
	cin >> n >> s1 >> m;
	int r = stoi(s1,NULL,n);
	x_to_n(r,m);
	return 0;
} 
